package com.keepers.repair.net;

import android.text.TextUtils;

import com.keepers.repair.helper.SpHelper;

import okhttp3.HttpUrl;

/**
 * auth aboom
 * date 2018/12/4
 */
public class HttpUtil {

    public static final String HTTP_HOST = "task.keepers.com.cn";
    public static final int    HTTP_PORT = 8089;

    private static String TEST_URL = getUrl(HTTP_HOST, HTTP_PORT);

    /**
     * 获取app当前的域名
     */
    public static String getUrlStart() {
        String currentHttpHost = SpHelper.getCurrentHttpHost();
        int currentHttpPort = SpHelper.getCurrentHttpPort();
        return TextUtils.isEmpty(currentHttpHost) ? TEST_URL : getUrl(currentHttpHost, currentHttpPort);
    }

    public static String getUrl(String httpHost, int httpPort) {
        return new HttpUrl.Builder()
                .scheme("http")
                .host(httpHost)
                .port(httpPort)
                .addPathSegment("WebService")
                .addPathSegment("MobileService.asmx")
                .build()
                .toString() + "/";
    }
}
